<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <style>
        div {
            width: 400px;
            height: 150px;
            border: 1px dashed red;
            margin: 10px 0;
        }
        p {
            border: 1px solid blue;
        }
    </style>
    </head>
    <script src='src1/icreate.core.js'></script>
     <script src='src1/icreate.dom.js'></script>
     <script>
     //方法一：
  /*   Icreate.fn.appendTo = function (arr){
     	//this，是伪数组，要将this[0] 加入到 arr[i]中
     	var tmp = [],tmpNode;
     	for( var j=0;j<this.length;j++ ){
     		for( var i=0;i<arr.length;i++ ){
	     		if(i==arr.length-1){
	     			tmp.push(this[j]);
	     			arr[i].appendChild(this[j])
	     		}else{
	     			tmpNode = this[j].cloneNode(true);
	     			tmp.push(tmpNode);
	     			arr[i].appendChild(tmpNode);
	     		}
     		}
     		return tmp;
     	}
     
     }*/

     //简单优化
     Icreate.fn.appendTo =function(arr){
     	var tmp =[],tmpNode;
     	for(var j=0;j<this.length;j++){
     		for(var i=0;i<arr.length;i++){
     			tmpNode = i == arr.length-1? this[ j ] : this[ j ].cloneNode( true );
     			tmp.push( tmpNode );
     			arr[i].appendChild(tmpNode);
     		}
     	}
     	return tmp;
     }


     </script>
    <body>
     <div></div>
    <div></div>
    <div></div>
    </body>
    <script>
    	// var p1 = I( '<p>ppp</p><p>ppp</p><p>ppp</p><p>ppp</p>' );
    	var p1 = I( '<p>ppp</p>');
    	var p2 = p1.appendTo( I('div') );

    </script>
</html>